<template>
    <el-dialog
        :model-value="modelValue"
        title=""
        width="927px"
        custom-class="preview-dialog"
        :close-on-click-modal="false"
        :show-close="false">
        <template #header>
            <div class="header">
                <span class="title">预览</span>
                <el-button class="close-btn" type="primary" link @click="close">X</el-button>
            </div>
         </template>
         <div class="content">
            <el-tabs v-model="currentTab" class="content-tabs">
                <el-tab-pane
                    v-for="tab in tabList"
                    :key="tab.key"
                    :label="tab.name"
                    :name="tab.key">
                    <div class="review-img-wrap">
                        <img class="review-img" :src="require('@/assets/img/user-photo.png')" alt="图片">
                        <!-- <img class="review-img" :src="tab.url" alt="图片"> -->
                    </div>
                </el-tab-pane>
            </el-tabs>
        </div>
    </el-dialog>
</template>


<script setup>
import { ref, defineProps, defineEmits, watchEffect } from 'vue';
import { useStore } from 'vuex'

const props = defineProps({
    modelValue: {
        type: Boolean,
        default: true
    },
    pcUrl: {
        type: String,
        default: ''
    },
    appUrl: {
        type: String,
        default: ''
    }
});

const emit = defineEmits(['update:modelValue']);

const store = useStore();

let currentTab = ref('');

let tabList = ref([]);

watchEffect(() => {
    if (props.modelValue) {
        currentTab.value = '';
        tabList.value = [];
    }

    if (props.pcUrl && props.appUrl) {
        tabList.value.push({name: 'PC预览', key: 'PC', url: props.pcUrl});
        tabList.value.push({name: 'app预览', key: 'app', url: props.appUrl});
        currentTab.value = 'app';
    } else {
        tabList.value.push({name: 'PC预览/app预览', key: 'other', url: props.pcUrl || props.appUrl});
        currentTab.value = 'other';
    }
})

// 关闭弹窗
function close () {
    emit('update:modelValue', false);
}

</script>

<style lang="scss">
.preview-dialog {
    .el-dialog__header {
        padding: 0;
        margin: 0;
    }
    .el-dialog__body {
        padding: 10px 24px 30px;
    }
    .header {
        display: flex;
        justify-content: space-between;
        align-items: cente;
        color: #000000;
        padding: 8px 24px 4px;
        border-bottom: 1px solid #ccc;
        .close-btn {
           color: #000000;
           &:hover {
               color: $--color-blue;
           }
        }
    }
    .content {
        .review-img-wrap {
            padding: 30px 50px;
            text-align: center;
            .review-img {
                max-width: 781px;
                max-height: 486px;
            }
        }
    }
}
</style>